#ifndef PAGE0_H
#define PAGE0_H

#include <QWidget>
#include<QSqlTableModel>
#include"src/mes.h"
#include<QTimer>

namespace Ui {
class Page0;
}

class Page0 : public QWidget
{
    Q_OBJECT

public:
    explicit Page0(QWidget *parent = nullptr);
    ~Page0();

private slots:
    void on_pushButton_2_clicked();

    void on_pushButton_3_clicked();

    void on_pushButton_clicked();

    void on_tabWidget_currentChanged(int index);

    void initTabText();

    void on_checkButton_clicked();

    void on_recheckButton_clicked();

    void on_maintainButton_clicked();

    void slot_createQRcode();
    void slot_copyData();
    void slot_repairApply();
    void slot_checkHistoryQuery();
    void slot_repairHistoryQuery();

    void slotContextMenu(QPoint);

private:
    Ui::Page0 *ui;

    void initTableView(QStringList sqlist);
    void initTab_2();
    void initTab_3();
    void initTab_4();
    void initCheckTreeWidget();
    void initRecheckTreeWidget();
    void initMaintainTreeWidget();

    QTimer *refreshTimer=new QTimer(this);
    int noticeFlag=0;
    void showNoticeDialog(int checkItems,int recheckItems,int maintainItems);

    QMap<QString,QList<QList<QVariant>>> checkMap;
    QMap<QString,QList<QList<QVariant>>> recheckMap;
    QMap<QString,QList<QList<QVariant>>> maintainMap;

    QMenu *popMenu;
    int selectCurrentRow;
    int selectCurrentColumn;
};



class MydeviceTable:public QSqlTableModel
{
    Q_OBJECT
public:
    MydeviceTable( QObject * parent = 0, QSqlDatabase db = Mes::getInstance()->db);

    void setSqlist(QStringList sqlist){this->sqlist=sqlist;};

private:
    QStringList sqlist;
    QStringList labels{"设备编号","设备名称","保管人工号","拥有数量","超期年限","经办人工号","领用时间",
        "存放地点","设备状态","检验时间","检验周期","检验项目","检验人工号"};

protected:
    QString selectStatement() const override;
    QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
};

#endif // PAGE0_H
